package ah.szxy.service.impl;

import ah.szxy.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * 远程调用接口服务
 *
 * @author caohaiyang
 * @create 2020-09-17 下午 04:25
 */
@Service
public class AccountServiceApi {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private OrderFeignService orderFeignService;

    /**
     * 发起对account-service的远程调用
     * @param userName
     * @param money
     * @return
     */
   /* public ResponseEntity<Void> debit(String userName, int money){
        ResponseEntity<Void> responseEntity = restTemplate.getForEntity("http://account-service/debit/{userName}/{money}",
                Void.class,
                userName, money);
        return responseEntity;
    }*/
    public ResponseEntity<Void> debit(String userName, int money){
        ResponseEntity<Void> responseEntity = orderFeignService.debit(userName, money);
        return responseEntity;
    }

}